import numpy as np
from cv2 import cv2
from PIL import ImageGrab
import time

# 图像传输原理
im1 = ImageGrab.grab() # 截取屏幕
time.sleep(1)
print('test')
im2 = ImageGrab.grab() # 截取屏幕

in1 = np.asarray(im1)
in2 = np.asarray(im2)

in3 = in2 - in1

cv2.imwrite("./1.png", in1)
cv2.imwrite("./2.png", in2)
cv2.imwrite("./sub.png", in3)  # 得到差异化图像

# 传输 in3 的差异
# 让 in1 + in3 得到 in2
# in2 = in1 + in3